
//import java.io.BufferedReader;
//import java.io.DataInputStream;
//import java.io.FileInputStream;
//import java.io.InputStream;
//import java.io.InputStreamReader;
//import java.io.ObjectInputStream.GetField;
//import java.net.DatagramSocket;
//import java.net.InetAddress;
//import java.net.SocketException;
//import java.net.UnknownHostException;
//
//
//public class VirtualRouter 
//{
//	public static void main(String[] args) throws UnknownHostException
//	{
////		boolean run = true; 
////				
////        try
////        {
////            // Open the file that is the first 
////            // command line parameter
////        
////        	
////            FileInputStream fstream = new FileInputStream("Command.txt");
////            // Get the object of DataInputStream
////            DataInputStream dstream = new DataInputStream(fstream);
////            BufferedReader br = new BufferedReader(new InputStreamReader(dstream));
////            String strLine;
////            //Read File Line By Line
////            while ((strLine = br.readLine()) != null)   
////            {
////              // Print the content on the console
////              System.out.println (strLine);
////            }
////            //Close the input stream
////            dstream.close();
////        }
////        catch (Exception e)
////        {
////              System.err.println("Error: " + e.getMessage());
////        }
//
//		InetAddress myIP = null;
//		DatagramSocket sock = null;
//		
//		try {
//			myIP = InetAddress.getLocalHost();
//			System.out.println("ip is " + myIP);
//			sock = new DatagramSocket(1000, myIP);
//		} catch (UnknownHostException e1) {
//			// TODO Auto-generated catch block
//			e1.printStackTrace();
//		} catch (SocketException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		
//		
//		System.out.println("inet address is " + sock.getInetAddress());
//		System.out.println("local address is " + sock.getLocalAddress());
//		System.out.println("local socket address is " + sock.getLocalSocketAddress());
//		
//		
//		byte [] IP = myIP.getAddress();
//		
//		for (int i = 0; i < IP.length; i++)
//		{
//			System.out.print(IP[i] + " ");
//		}
//		
//		System.out.println();
//		
//		IP[3] = 66;
//		
//		
////		InetAddress testIP = null;
////		DatagramSocket tSock = null;
////		
////		try {
////			testIP = InetAddress.getByAddress(IP);
////			sock = new DatagramSocket(1001, testIP);
////		} catch (UnknownHostException e1) {
////			// TODO Auto-generated catch block
////			e1.printStackTrace();
////		} catch (SocketException e) {
////			// TODO Auto-generated catch block
////			e.printStackTrace();
////		}
////		
////		System.out.println("inet address is " + tSock.getInetAddress());
////		System.out.println("local address is " + tSock.getLocalAddress());
////		System.out.println("local socket address is " + tSock.getLocalSocketAddress());
//		
//		
//		
//		
//		if (sock.isConnected())
//		{
//			System.out.println("connected");
//			
//		}
//		
//		sock.close();
//        
//
//    }
//	
//}

import java.net.*;
import java.util.*;

class VirtualRouter
{
	DatagramSocket harbor = null;

	public VirtualRouter()
	{

	}

	private boolean connect()
	{

		return true;
	}

	public static void main(String args[]) throws Exception
	{
		DatagramSocket socket = new DatagramSocket(7);
		System.out.println("socket made");
		DatagramPacket packet = new DatagramPacket(new byte[512], 512);
		System.out.println("packet made");
		while (true)
		{
			System.out.println("while loop entered");
			socket.receive(packet);
			System.out.println("" + new Date() + " " + packet.getAddress()
					+ ":" + packet.getPort() + " "
					+ new String(packet.getData(), 0, packet.getLength()));
			socket.send(packet);
		}
		
		
		
		
		
		
		
		

//        
//        try
//        {
//            // Open the file that is the first 
//            // command line parameter
//        
//                
//            FileInputStream fstream = new FileInputStream("Command.txt");
//            // Get the object of DataInputStream
//            DataInputStream dstream = new DataInputStream(fstream);
//            BufferedReader br = new BufferedReader(new InputStreamReader(dstream));
//            String strLine;
//            //Read File Line By Line
//            while ((strLine = br.readLine()) != null)   
//            {
//              // Print the content on the console
//              System.out.println (strLine);
//            }
//            //Close the input stream
//            dstream.close();
//        }
//        catch (Exception e)
//        {
//              System.err.println("Error: " + e.getMessage());
//        }
	}
}
